﻿@using CoreData
@using Helper
@model IEnumerable<OrderService>
@if (Model != null && Model.Count() > 0)
{
    var id = "tSortable" + Model.First().Status;
    <table cellpadding="0" cellspacing="0" width="100%" class="table" id="@id">
        <thead>
            <tr>
                <th>
                    Mã đơn hàng
                </th>
                <th>
                    Tên khách hàng
                </th>
                <th>
                    @if (@ViewBag.TypeID == (int)ValueDefine.OrderServiceType.hotel)
                    { 
                        <span>Khách sạn</span>
                    }
                    else if (@ViewBag.TypeID == (int)ValueDefine.OrderServiceType.vehicle)
                    { 
                        <span>Phương tiện</span>
                    }
                </th>
                <th>
                    Ngày tạo
                </th>
                <th>
                    Tình trạng
                </th>
                <th width="60px">
                    Chức năng
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        #@item.ID
                    </td>
                    <td>
                        <span class="SpanId" style="display: none;">@item.ID</span> <span class="SpanName"
                            style="display: none;">@item.Name</span>
                        @item.Name
                    </td>
                    <td>@item.ReferenceNameExt
                    </td>
                    <td>@item.CreateDate.ToString("dd/MM/yyyy hh:mm:ss tt")
                    </td>
                    <td>
                        @if (item.Status == 1)
                        {
                            <span class="orderlabel new-order">Đơn hàng mới</span> 
                        }
                        @if (item.Status == 2)
                        {
                            <span class="orderlabel pending-order">Đang xử lý</span> 
                        }
                        @if (item.Status == 3)
                        {
                            <span class="orderlabel complete-order">Hoàn thành</span> 
                        }
                        @if (item.Status == 4)
                        {
                            <span class="orderlabel paid-order">Đã thanh toán</span> 
                        }
                        @if (item.Status == 5)
                        {
                            <span class="orderlabel cancel-order">Yêu cầu hủy</span> 
                        }
                    </td>
                    <td>
                        @if (Helper.SessionManagement.Value("pvalue").Contains("R"))
                        {
                            <a title="Chi tiết" href="@Url.Action("Details", "OrderServiceManagement", new { id = item.ID })" class="icon-eye-open">
                            </a>
                        }
                        @if (Helper.SessionManagement.Value("pvalue").Contains("U") || Helper.SessionManagement.Value("pvalue").Contains("C"))
                        {
                            <a title="Sửa" href="@Url.Action("AddOrUpdate", "OrderServiceManagement", new { id = item.ID })" class="icon-pencil">
                            </a>
                        }
                        @if (Helper.SessionManagement.Value("pvalue").Contains("D"))
                        {
                            <a title="Xóa" href="@Url.Action("Delete", "OrderServiceManagement", new { id = item.ID })" class="icon-trash" onclick="return confirm('Có chắc bạn muốn xóa ?');">
                            </a>
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
}
else
{
    <h2 class="error-text">
        Không tìm thấy dữ liệu.
    </h2>
}